package com.zhuxulin.tab.utils;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.zhuxulin.tab.R;

public class DataUtils {
	private static String TAG=DataUtils.class.getSimpleName();
	public static List<Map<String, Object>> getListMap(File dir) {
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		Map<String, Object> map = null;
		File[] files = FileUtils.listFiles(null, dir);
		for (File file : files) {
			map = new HashMap<String, Object>();
			map.put("title", file.getName());
			map.put("info", "info");
			if(file.isDirectory()){
				map.put("img", R.drawable.floder);
			}else{
				map.put("img", R.drawable.music);
			}
			map.put("file", file);
			map.put("size", file.length()/1024+"KB");
			list.add(map);
		}
		return list;
	}

	public static List<Map<String, Object>> getListMap(String dir) {
		return (dir != null && !dir.trim().equals("")) ? getListMap(new File(
				dir)) : null;
	}
}
